#ifndef GENAGENT_H
#define GENAGENT_H

#include <QObject>
#include <QList>
#include "protocol.h"

class GenAgent: public QObject
{
	Q_OBJECT

	public:
		GenAgent(int genId, const TGenConfig& genConfig);
		~GenAgent();
		TGenConfig getConfig();
		int getGenId();
		void setGenConfig(TGenConfig config);
		void setGenId(int genId);

	private:
		QTcpSocket *m_socket; // use to send and recv data
		int m_genId;
		TGenConfig m_genConfig;
		QList<TTranData> oldTranDataList;

	signals:
		void connectCompleted(int genId, int status);
		void commandCompleted(int genId, int cmdType, int status);
		void tranDataArrived(int genId, QList<TTranData> incTranData);
		void userDataArrived(int genId, int incUser);

	private slots:
		void readReadyHandle(); // recv reply from generator

	public slots:
		void ConnectGenerator(int genId, TGenConfig config); // make sure the generator can work
		void SendCommand(int genId, int type); // send command like start, stop...
		void SendProfile(TProfile profile); // send generator profile
		void InitAgent();
};

#endif
